#include "common.h"
#include "arrayStack.h"
#include "linkStack.h"

// 测试顺序栈
void test01() {
    ArrayStack *stack = createArrayStack();
    if (stack == NULL) {
        return;
    }
    for (int i = 0; i < 5; ++i) {
        pushArrayStack(stack, i + 10);
    }
    printf("push 5 element!\n");
    pushArrayStack(stack, 500);
    // 一直弹，弹完为止
    Element e;
    while (popArrayStack(stack, &e) == 0) {
        printf("%d\t", e);
    }
    printf("===============\n");
    releaseArrayStack(stack);
}

// 测试链式栈
void test02() {
    LinkStack *stack = createLinkStack();
    for (int i = 0; i < 5; ++i) {
        pushLinkStack(stack, i + 50);
    }
    printf("There are %d element on the stack!\n", stack->count);
    printf("pop: \n");
    Element e;
    while (popLinkStack(stack, &e) == 0) {
        printf("%d\t", e);
    }
    printf("===============\n");
    releaseLinkStack(stack);
}

int main() {
    test02();

    return 0;
}
